package com.work.straighttalk.presenter;

import android.util.Log;

import com.work.straighttalk.bean.Notifyfriends;
import com.work.straighttalk.model.NewFriendsMImpl;
import com.work.straighttalk.model.i.NewFriendsMI;
import com.work.straighttalk.model.i.OnNewFriendsListener;
import com.work.straighttalk.presenter.i.NewFriendsPI;
import com.work.straighttalk.ui.i.NewFriendsVI;

import java.util.List;

/**
 * Created by dllo on 16/3/7.
 */
public class NewFriendsPImpl implements NewFriendsPI, OnNewFriendsListener {
    private NewFriendsVI newFriendsVI;
    private NewFriendsMI newFriendsMI;

    public NewFriendsPImpl(NewFriendsVI newFriendsVI) {
        this.newFriendsVI = newFriendsVI;
        this.newFriendsMI = new NewFriendsMImpl();
    }

    @Override
    public void validateUsername(String username) {
        if (newFriendsVI != null) {
            newFriendsMI.verifications(username, this);
            Log.d("NewFriendsPImpl58415", username);
        }
    }

    @Override
    public void onDestroy() {
        newFriendsVI = null;
    }

    @Override
    public void getNewFriendsList(List<Notifyfriends> list) {
        if (newFriendsVI != null) {
            newFriendsVI.updateItem(list);
        }
    }

    @Override
    public void refresh() {
        newFriendsMI.verifications(this);
    }

    @Override
    public void onSuccess() {

    }
}
